package es.ats.codington.festival.daos;

import java.util.Properties;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

import es.ats.codington.festival.interfaces.daos.iEventDAO;
import es.ats.codington.festival.interfaces.daos.iEventSignUpDAO;
import es.ats.codington.festival.interfaces.daos.iPlaceDAOImpl;
import es.ats.codington.festival.interfaces.daos.iVisitorDAO;


/**
 * The Class DAOManager.
 */
public class DAOManager {
	
	/** The data source. */
	private DataSource dataSource;
	
	/** The query properties. */
	private Properties queryProperties;
	
	/** The jdbc template. */
	private JdbcTemplate jdbcTemplate; 


	/**
	 * Sets the query properties.
	 *
	 * @param queryProperties the new query properties
	 */
	public void setQueryProperties(Properties queryProperties) {
		this.queryProperties = queryProperties;
	}


	/**
	 * Sets the jdbc template.
	 *
	 * @param jdbcTemplate the new jdbc template
	 */
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate){  
		this.jdbcTemplate = jdbcTemplate;  
	}  

	
	/**
	 * Sets the data source.
	 *
	 * @param dataSource the new data source
	 */
	public void setDataSource(DataSource dataSource) {  
		this.jdbcTemplate = new JdbcTemplate(dataSource);  
	}  
	
	
	/**
	 * Return an instance of JdbcTemplate.
	 *
	 * @return JdbcTemplate
	 */
	public JdbcTemplate getTemplate(){  
		return jdbcTemplate;  
	}  


	/**
	 * Return an instance of IEventDAO.
	 *
	 * @return EventDAO
	 */
	public iEventDAO getEventDAO() {		 	
		return new EventDAOImpl(jdbcTemplate,queryProperties);				 			
	}		 	


	/**
	 * Return an instance of IPlaceDAO.
	 *
	 * @return IPlaceDAO
	 */
	public iPlaceDAOImpl getPlaceDAO() {
		return new PlaceDAOImpl(jdbcTemplate,queryProperties);				
	}

	
	
	/**
	 * Return an instance of IEventSignUpDAO.
	 *
	 * @return IEventSignUpDAO
	 */
	public iEventSignUpDAO getEventSignUpDAO() {
		return  new EventSignUpDAOImpl(jdbcTemplate, queryProperties);		
	}
	
	/**
	 * Gets the visitor dao impl.
	 *
	 * @return the visitor dao impl
	 */
	public iVisitorDAO getVisitorDAOImpl(){
		return new VisitorDAOImpl(jdbcTemplate, queryProperties);
	}

}

